package com.kly.order.db.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.google.common.collect.Maps;
import com.kly.order.db.dao.PSubscriptionLogDao;
import com.kly.order.db.entity.PSubscriptionLogEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

/**
* User: linqu
* Date: 2024-01-17
* Time: 10:39:42.059
*/

@Repository
public class PSubscriptionLogDaoImpl extends AbstractBaseMapper<PSubscriptionLogEntity> implements PSubscriptionLogDao {

    @Override
    public PSubscriptionLogEntity getPSubscriptionLogByMessageId(String messageId) {
        return this.getSqlSession().selectOne(this.getStatement("getPSubscriptionLogByMessageId"), messageId);
    }

    @Override
    public int updateSubscriptionStatus(String messageId, Integer status, String msg) {
        final HashMap<Object, Object> params = Maps.newHashMap();
        params.put("messageId", messageId);
        params.put("status", status);
        params.put("responseMsg", msg);
        return this.getSqlSession().update(this.getStatement("updateSubscriptionStatus"), params);
    }

    @Override
    public int updateSubscription(String messageId, String token, String orderId) {
        final HashMap<Object, Object> params = Maps.newHashMap();
        params.put("orderId", orderId);
        params.put("token", token);
        params.put("messageId", messageId);
        return this.getSqlSession().update(this.getStatement("updateSubscription"), params);
    }

    @Override
    public int subscriptionSuccess(String orderId, String msg) {
        final HashMap<Object, Object> params = Maps.newHashMap();
        params.put("orderId", orderId);
        params.put("responseMsg", msg);
        return this.getSqlSession().update(this.getStatement("subscriptionSuccess"), params);
    }

    @Override
    public List<PSubscriptionLogEntity> listSubscriptFailRecord() {
        return this.getSqlSession().selectList(this.getStatement("listSubscriptFailRecord"));
    }
}